package me.sealer.demo;

import java.lang.ref.WeakReference;

/**
 * Created by sealer on 17/05/15.
 */
public class ReferenceTest {
    public static void main(String[] args) {
        MyObject obj = new MyObject();
//        SoftReference<MyObject> softReference = new SoftReference<>(obj);
        WeakReference<MyObject> weakReference = new WeakReference<>(obj);
//        PhantomReference<MyObject> phantomReference = new PhantomReference<>(obj, new ReferenceQueue<MyObject>());
        obj = null;
//        System.gc();
        System.gc();

    }

    static class MyObject {
        @Override
        protected void finalize() throws Throwable {
            System.out.println("gc myObject...");
        }
    }
}
